package com.mvd.app.api;

import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter;

import java.io.IOException;

/**
 * @ProjectName: PDA_An_2020
 * @Package: com.mvd.app.api
 * @ClassName: StringAdapter
 * @Description: java类作用描述
 * @Author: liuxj
 * @CreateDate: 2023-03-09 10:18
 * @UpdateUser: 更新者
 * @UpdateDate: 2023-03-09 10:18
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public   class StringAdapter extends TypeAdapter<String> {
    public String read(JsonReader reader) throws IOException {
        if (reader.peek() == JsonToken.NULL) {
            reader.nextNull();
            return "";
        }
        if (reader.peek() == JsonToken.BOOLEAN) {
            reader.nextBoolean();
            return "";
        }
        return reader.nextString();
    }

    public void write(JsonWriter writer, String value) throws IOException {

    }
}